package pseudoAssemblerCompiler.twopassassembler.model.codeoperationtable;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
import pseudoAssemblerCompiler.twopassassembler.model.Utils;
import pseudoAssemblerCompiler.twopassassembler.model.entities.OperationCode;

/**
 * Created with IntelliJ IDEA.
 * User: Администратор
 * Date: 15.04.12
 * Time: 18:07
 * To change this template use File | Settings | File Templates.
 */
public class OperationCodeLabelProvider implements ITableLabelProvider {
    @Override
    public Image getColumnImage(Object o, int i) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getColumnText(Object element, int columnIndex) {
        OperationCode operationCode = (OperationCode) element;
        if (null == operationCode) {
            return null;
        }
        switch (columnIndex) {
            case 0:
                return operationCode.get_mnemonicCode();
            case 1:
                return Utils.addrBuild(operationCode.get_binaryCode(), 2);
            case 2:
                return Integer.toString(operationCode.get_lengthOfCommand());
            case 3:
                return Integer.toString(operationCode.get_typeOfAddressing());
            case 4:
                return Boolean.toString(operationCode.is_directive());
        }
        return "Hello";
    }

    @Override
    public void addListener(ILabelProviderListener iLabelProviderListener) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void dispose() {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isLabelProperty(Object o, String s) {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void removeListener(ILabelProviderListener iLabelProviderListener) {
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
